Skip to content

refactor(registry/coder/modules/coder-utils)!: derive names from module_directory#874

Merged
matifali merged 3 commits intomainfrom
chore/coder-utils-module-directory-refactor
Apr 24, 2026
Merged

refactor(registry/coder/modules/coder-utils)!: derive names from module_directory#874
matifali merged 3 commits intomainfrom
chore/coder-utils-module-directory-refactor

Conversation

@matifali
Copy link
Copy Markdown
Member

@matifali matifali commented Apr 24, 2026

Summary

Derives coder-utils script names from module_directory instead of a separate agent_name input. The module_directory already encodes both the namespace and the module name, so carrying both is redundant and error-prone. Callers like claude-code no longer need to pass agent_name.

Scripts this module materializes lose the ${agent_name}-utils- prefix because module_directory already namespaces them per-caller.

We will address multiple instances of coder-utils per caller in a future iteration if needed.

Versioning Note

Previous tags (v1.0.0 through v1.3.0) have been deleted because no published module ever consumed them — the module was effectively unreleased. This PR ships the first real public version as v0.0.1, treating it as a fresh start rather than a breaking bump from a version that was never in production use.

Changes

  • Remove agent_name variable.
  • Derive caller_name = "${namespace}-${module_name}" from module_directory.
  • Validate module_directory matches $HOME/.coder-modules/<namespace>/<module-name>.
  • Rename script files on disk from ${agent_name}-utils-<phase>.sh to plain <phase>.sh.
  • Add a TS test for the module_directory validation.
  • Ship as v0.0.1 (first published version; all prior tags removed).

Breaking Changes

Before After
agent_name = "myagent" removed (derived from module_directory)
module_directory = ".my-module" module_directory = "$HOME/.coder-modules/<ns>/<name>" (validated)
Script files ${agent_name}-utils-install.sh install.sh
Script sync names ${agent_name}-install_script ${namespace}-${module_name}-install_script

No callers were depending on the old format (prior tags were unpublished).

Validation

  • terraform fmt -recursive clean
  • terraform validate clean
  • terraform test → 17/17 pass
  • bun test registry/coder/modules/coder-utils → 5/5 pass
  • prettier --check clean

Consumer

#861 (claude-code) consumes this and is currently pinned to the commit SHA until this merges and ships as v0.0.1.

🤖 This PR was created with the help of Coder Agents, and needs a human review. 🧑‍💻

…t test

- README: set the usage example version to 2.0.0. The previous value
  was a placeholder.
- main.test.ts: prettier-format the imports and expect line.
@matifali matifali force-pushed the chore/coder-utils-module-directory-refactor branch from de3d8a4 to cfa7a24 Compare April 24, 2026 07:33
@matifali matifali requested a review from 35C4n0r April 24, 2026 07:59
@matifali matifali marked this pull request as ready for review April 24, 2026 07:59
@35C4n0r
Copy link
Copy Markdown
Collaborator

35C4n0r commented Apr 24, 2026

@matifali If we merge this:

  • Users won't have the freedom to write outside of the defined regex, even when they are building modules for their personal use.
  • we need to make sure to mention we cannot have 2 instances of the coder-utils module write to same module_directory, even when both of them are instantiated in the same parent module, they'll need to choose 2 different paths.
  • Every parent module that will use this module, will also need to implement that regex requirement, for example we'll need to copy the validation block to claude-code, gemini, copilot, codex etc., imo it wouldn't be a good UX for users considering we allow them to specify the module directory but enforce path restrictions.

@matifali
Copy link
Copy Markdown
Member Author

Every parent module that will use this module, will also need to implement that regex requirement, for example we'll need to copy the validation block to claude-code, gemini, copilot, codex etc., imo it wouldn't be a good UX for users considering we allow them to specify the module directory but enforce path restrictions.

This is not required. terraform will fail even if the nested validation fails

Users won't have the freedom to write outside of the defined regex, even when they are building modules for their personal use.

That is fine. Being restrictive is better than permissive. We can relax it later if needed.

we need to make sure to mention we cannot have 2 instances of the coder-utils module write to same module_directory, even when both of them are instantiated in the same parent module, they'll need to choose 2 different paths.

I think it is ok. We are the only consumer of this module today. We can add support for multiple instances when needed.

@matifali matifali merged commit 3b64d99 into main Apr 24, 2026
4 checks passed
@matifali matifali deleted the chore/coder-utils-module-directory-refactor branch April 24, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants